gdksurface-win32.c: Fix window menu positioning
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 12 Mar 2021 10:39:04 +0000 (18:39 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 12 Mar 2021 10:45:43 +0000 (18:45 +0800)
We ought to get the coordinates of where the window menu should be
displayed using gdk_win32_surface_get_root_coords(), instead of rounding
the position that we obtained with gdk_event_get_position().

Also rename items a bit in the same function, and call
gdk_event_get_event_type() for consistency with the other backends.

Fixes issue #3704.

gdk/win32/gdksurface-win32.c

index cd113bc4df7c0fff288e65123f0948d4c8d8c14c..d600996fe25300d3e2ce0097c984b4286187def5 100644 (file)
@@ -4279,14 +4279,15 @@ gdk_win32_surface_is_win32 (GdkSurface *window)
 }
 
 static gboolean
-gdk_win32_surface_show_window_menu (GdkSurface *window,
-                                   GdkEvent  *event)
+gdk_win32_surface_show_window_menu (GdkSurface *surface,
+                                    GdkEvent  *event)
 {
   double event_x, event_y;
   int x, y;
-  GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
+  GdkWin32Surface *impl = GDK_WIN32_SURFACE (surface);
+  GdkEventType event_type = gdk_event_get_event_type (event);
 
-  switch ((int) event->event_type)
+  switch ((int) event_type)
     {
     case GDK_BUTTON_PRESS:
     case GDK_BUTTON_RELEASE:
@@ -4298,10 +4299,9 @@ gdk_win32_surface_show_window_menu (GdkSurface *window,
     }
 
   gdk_event_get_position (event, &event_x, &event_y);
-  x = round (event_x);
-  y = round (event_y);
+  gdk_win32_surface_get_root_coords (surface, event_x, event_y, &x, &y);
 
-  SendMessage (GDK_SURFACE_HWND (window),
+  SendMessage (GDK_SURFACE_HWND (surface),
                WM_SYSMENU,
                0,
                MAKELPARAM (x * impl->surface_scale, y * impl->surface_scale));